package com.example.controller;

import com.example.pojo.Result;
import com.example.pojo.assemblyEquipmentPojo;
import com.example.pojo.faultHistoryPojo;
import com.example.service.assemblyEquipmentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * ClassName:assemblyEquipment
 * Description:
 *
 * @Author 赵永峰
 * @Create 2024/9/28 19:41
 * @Version 1.0
 */
@RestController
@Slf4j
public class assemblyEquipmentController {
    @Autowired
    private assemblyEquipmentService assemblyEquipmentService;
    //在主表中插入一行数据
    @PostMapping("/assemblyEquipmentInsert")
    public Result assemblyEquipmentInsert(@RequestBody assemblyEquipmentPojo assemblyEquipmentPojo){
        assemblyEquipmentService.insertOne(assemblyEquipmentPojo);
        return Result.success(assemblyEquipmentPojo);
    }
    //点击导航，查询出大表数据
    @PostMapping("/assemblyEquipmentInquiryTree")
    public Result assemblyEquipmentInquiryTree(@RequestBody Map<String,Object> objectMap){
        List<assemblyEquipmentPojo> list=assemblyEquipmentService.inquiryByTowFiled(objectMap);
        return Result.success(list);
    }
    //根据id，修改一行数据
    @PostMapping("/assemblyEquipmentEdit")
   public Result assemblyEquipmentEdit(@RequestBody assemblyEquipmentPojo assemblyEquipmentPojo){
        assemblyEquipmentService.editById(assemblyEquipmentPojo);
        return Result.success();
   }
   //根据传来的数据，修改一个字段，根据id修改
    @PostMapping("/assemblyEquipmentEditOneById")
    public Result assemblyEquipmentEditOneById(@RequestBody Map<String,Object> map){
        assemblyEquipmentService.EditOneById(map);
        return Result.success(map.get("filedVal"));
    }
    //对设备问题插入一行数据
    @PostMapping("assemblyEquipmentFaultHistoryInsert")
    public Result assemblyEquipmentFaultHistoryInsert(@RequestBody faultHistoryPojo faultHistoryPojo){
        //向后端插入一条数据
        assemblyEquipmentService.assemblyEquipmentFaultHistoryInsert(faultHistoryPojo);
        return Result.success("插入成功");
    }
    //设备人员到位了，要处理问题，进行到位时间记录，筛选出本序还没有人处理的问题
    @PostMapping("/assemblyEquipmentFaultHistoryFirstReach")
    public Result assemblyEquipmentFaultHistoryFirstReach(@RequestBody Map<String,Object> map){
        List<faultHistoryPojo> faultHistoryPojos=assemblyEquipmentService.assemblyEquipmentFaultHistoryFirstReach(map);
        return Result.success(faultHistoryPojos);
    }
}
